home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / snpd1292.zip / ABSDISK.ASM next >
Assembly Source File  |  1992-12-26  |  2KB  |  73 lines

  1.         page    55, 132
  2.  
  3. ;
  4. ;  ABSDISK.ASM
  5. ;
  6. ;  Originally published as part of The MicroFirm Function Library
  7. ;  This version released to the public domain by the author, Bob Stout
  8. ;
  9. ;  Requires MASM 5.1 or later or equivalent
  10. ;
  11. ;  Assemble with:       MASM /Mx /z ...
  12. ;                       TASM /jMASM /mx /z ...
  13. ;
  14.  
  15. %       .MODEL  memodel,C               ;Add model support via
  16.                                         ;command line macro,
  17.                                         ;e.g. MASM /Dmemodel=LARGE ...
  18.         extrn   _osmajor:BYTE
  19.         public  absdisk
  20.  
  21.         .DATA
  22. start   dw      ?
  23. fill    dw      0
  24. number  dw      ?
  25. buf     dw      ?,?
  26.  
  27.         .CODE
  28. absdisk PROC USES SI DI BP, func:BYTE, drive:WORD, num_sec:WORD, start_sec:WORD, buffer:PTR
  29.         mov     AX,drive        ;Get drive number in AL
  30.         mov     AH,_osmajor     ;Load OS version in AH
  31.         mov     CX,num_sec      ;Set up regs for DOS 3 call
  32.         mov     DX,start_sec
  33.     IF  @DataSize
  34.         push    DS              ;Save DS in L & C models
  35.         lds     BX,buffer
  36.     ELSE
  37.         mov     BX,buffer
  38.     ENDIF
  39.         cmp     AH,4            ;DOS 4+?
  40.         jb      doint           ;No, skip it
  41.         mov     start,DX        ;Yes, fill in DCB structure
  42.         mov     number,CX
  43.         mov     buf,BX
  44.         mov     buf+2,DS
  45.         mov     cx,-1
  46.     IF  @DataSize               ;Point to DCB
  47.         mov     BX,@Data
  48.         mov     DS,BX
  49.     ENDIF
  50.         mov     bx,OFFSET start
  51. doint:  mov     AH,func         ;Read or Write?
  52.         cmp     AH,25h
  53.         jne     skip_1
  54.         int     25h             ;Read sector
  55.         jmp     skip_3
  56. skip_1: cmp     AH,26h
  57.         jne     skip_2
  58.         int     26h             ;Write sector
  59.         jmp     skip_3
  60. skip_2: stc
  61. skip_3: mov     AX,0            ;Set up no error return
  62.         jnc     bye             ;Error?
  63.         dec     AX              ;Yes, flag it
  64. bye:    add     SP,2            ;Int 25h leave the flags on the stack
  65.     IF  @DataSize
  66.         pop     DS              ;Restore DS in L & C models
  67.     ENDIF
  68.         ret
  69.  
  70. absdisk ENDP  
  71.  
  72.         end
  73.